class ArticleModel {
  List<ArticleItemModel> data;
  int pageSize;
  int totalItems;
  int totalPages;

  ArticleModel({
    this.data,
    this.pageSize,
    this.totalItems,
    this.totalPages,
  });

  String getLastCursor() {
    return data == null ? "" : data[data.length - 1].getLastCursor();
  }

  ArticleModel.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = List<ArticleItemModel>();
      json['data'].forEach((v) {
        ArticleItemModel item = ArticleItemModel.fromJson(v);
        data.add(item);
      });
    }
    pageSize = json['pageSize'];
    totalItems = json['totalItems'];
    totalPages = json['totalPages'];
  }
}

class ArticleItemModel {
  int order;
  int publishTime = 0;
  ArticleItemModel.fromJson(Map<String, dynamic> json) {}

  String getLastCursor() {
    if (order != null) {
      return order.toString();
    }
    return publishTime != null ? publishTime.toString() : "";
  }
}
